/* initial */

function animationInit (index) {
    /* config panel */
    ocom.config.doms.configBar.onclick = (e) => {
        if (ocom.config.isopen) {
            ocom.config.doms.config.style.animation = 'ani-config-hide 0.3s ease 0s 1 alternate forwards';    // home\animation.css@ani-config-hide
            ocom.config.isopen = false;
        } else {
            ocom.config.doms.config.style.animation = 'ani-config-show 0.3s ease 0s 1 alternate forwards';    // home\animation.css@ani-config-show
            ocom.config.isopen = true;
        }
    }
}

let infoPrintInterval = null;
function infoPrint (str, noterr=0, scale=30) {
    let i = 0;
    if (infoPrintInterval != null) {
        clearInterval(infoPrintInterval);
    }
    ocom.body.doms.infoMsg.innerHTML = '';
    /* if noterr isn't a BOOL, the style will not change */
    if (typeof noterr == 'boolean') {
        if (noterr) {
            ocom.body.doms.info.style.animation = 'ani-info-noerr 0.3s ease 0s 1 alternate forwards';
            ocom.body.doms.infoMsg.style.animation = 'ani-infomsg-noerr 0.3s ease 0s 1 alternate forwards';
        } else {
            ocom.body.doms.info.style.animation = 'ani-info-err 0.3s ease 0s 1 alternate forwards';
            ocom.body.doms.infoMsg.style.animation = 'ani-infomsg-err 0.3s ease 0s 1 alternate forwards';
        }
    }
    infoPrintInterval = setInterval(() => {
        if (i < str.length) {
            ocom.body.doms.infoMsg.innerHTML += str[i++];
        } else {
            clearInterval(infoPrintInterval);
        }
    }, scale);
}